<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <link rel="Shortcut Icon" href="../images/aecc.ico" type="image/x-icon" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="../StaticFiles/element-ui/element-ui.css">
  <link rel="stylesheet" href="../StaticFiles/nprogress/nprogress.min.css">
  <link rel="stylesheet" href="../styles/vue-page-common.css">
  <script src="../Scripts/vue.min.js"></script>
  <script src="../StaticFiles/element-ui/element-ui.js"></script>
  <script src="../Scripts/axios.min.js"></script>
  <script src="../StaticFiles/nprogress/nprogress.min.js"></script>
  <script src="../Scripts/dayjs.min.js"></script>
  <script src="../Scripts/axios.config.js"></script>
  <title>压缩、解压工具报表</title>
</head>

<body>
  <div id="app" v-cloak v-on:keyup.enter="getData()">
    <!-- 报表标题 -->
    <vue2-report-header :title="'压缩、解压工具报表'"></vue2-report-header>
    <div style="padding: 10px;">
      <el-input type="textarea" :rows="10" placeholder="请输入需要压缩或解压的内容" v-model="originString">
      </el-input>

      <div style="margin:10px 0px;">
        <el-button type="primary" size="small" @click="zip">压缩</el-button>
        <el-button type="success" size="small" @click="unzip">解压</el-button>
      </div>

      <el-input type="textarea" :rows="10" v-model="resultString"></el-input>
    </div>
  </div>

  <script type="module">
    import Vue2ReportHeader from '../Scripts/components/Vue2ReportHeader.js'
    const app = new Vue({
      el: '#app',
      components: { Vue2ReportHeader },
      data: {
        originString: '',//需要压缩/解压的字符串
        resultString: '',//压缩或解压之后的字符串
      },
      methods: {
        // 压缩
        async zip() {
          const { data: { data, meta, total } } = await axios({
            method: 'post',
            url: '../handler/report/CommonActionHandle.ashx?action=getZip',
            data: { type: 'getZip', originString: this.originString }
          })
          if (meta.status === 500) { return this.$message.error(meta.msg); }
          this.resultString = data;
        },
        // 解压
        async unzip() {
          const { data: { data, meta, total } } = await axios({
            method: 'post',
            url: '../handler/report/CommonActionHandle.ashx?action=getUnzip',
            data: { type: 'getUnzip', originString: this.originString }
          })
          if (meta.status === 500) { return this.$message.error(meta.msg); }
          this.resultString = data;
        },
      },
      async mounted() { }
    })
  </script>
</body>

</html>